unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  Figure = class
    x, y: integer;
    procedure Draw; virtual; abstract;
  end;
  Circle = class(Figure)
    R, c: integer;
    constructor Create(newC: integer);
    procedure Draw; override;
  end;
  Square = class(Figure)
    a: integer;
    procedure Draw; override;
  end;
  FixedSquare = class(Square)
    constructor Create(newX, newY, newA: integer);
  end;
  RandomSquare = class(Square)
    constructor Create;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  mass : array [0..99] of Figure;
  i : integer;
begin
  Form1.Image1.Canvas.Brush.Color:=clWhite;
  Image1.Canvas.Rectangle(0, 0, Image1.Width, Image1.Height);
  for i := 0 to 49 do
  begin
    mass[i] := Circle.Create (clRed);
  end;
  for i := 50 to 74 do
    //Form1.Image1.Canvas.Brush.Color:=i*100-90;
    mass[i] := RandomSquare.Create;
  for i := 74 to 99 do
    //Form1.Image1.Canvas.Brush.Color:=i*47-32;
    mass[i] := FixedSquare.Create (10*i, 10*i, 50);
    for i := 00 to 99 do
       mass [i].Draw;
end;

{ Circle }

constructor Circle.Create(newC: integer);
begin
  c := newC;
  x := random(Form1.Image1.Width);
  y := random(Form1.Image1.Height);
  r := random(50)+20;
end;

procedure Circle.Draw;
begin
  Form1.Image1.Canvas.Brush.Color:=c;
  Form1.Image1.Canvas.Ellipse(x, y, x+r, y+r);
end;

{ RandomSquare }

constructor RandomSquare.Create;
begin
  x := random(Form1.Image1.Width);
  y := random(Form1.Image1.Height);
  a := random(100)+20;
end;

{ Square }

procedure Square.Draw;
begin
  Form1.Image1.Canvas.Rectangle(x, y, x+a div 2, y+a div 2);
end;

{ FixedSquare }

constructor FixedSquare.Create(newX, newY, newA: integer);
begin
  x:=newX;
  y:=newY;
  a:=newA;
end;

end.
